package Game.Items;

import java.lang.reflect.InvocationTargetException;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Vector2f;

import Game.Objects.GameObject;

/** Game item base class 
 * @author Aikidos
 */
public class GameItem {
	/** Is On? */
	protected boolean _isOn = false;
	
	/** Is can be deleted from inventory? */
	protected boolean _isCanBeDeleted = true;
	
	/** Item is stackable? */
	protected boolean _isStackable = false;
	
	/** Item name */
	protected String _name;
	
	/** Item cost */
	protected int _cost;
	
	/** Item weight */
	protected float _weight;
	
	protected GameObject _ownerGameObject;
	
	/** Number of items (if item is stackable) */
	private int _numOfItems;
	
	/** Is equip item? */
	public boolean IsEquip = false;

	/** Item category */
	public ECategory Category = ECategory.None;
	
	public enum ECategory {
		None,
		Potion,
		Weapon,
		Helmet,
		Chestplate,
		Shield,
		Gloves,
		Boots,
		Other
	}
	
	public GameItem(String name) {
		_name = name;
	}
	
	/** Returns true if item is on
	 * @return True if item is on
	 */
	public boolean isOn() {
		return _isOn;
	}
	
	/** Returns true if item can be deleted
	 * @return True if item can be deleted
	 */
	public boolean isCanBeDeleted() {
		return _isCanBeDeleted;
	}
	
	/** Item is stackable? */
	public boolean isStackable() {
		return _isStackable;
	}
	
	/** Returns item name
	 * @return Item name
	 */
	public String getName() {
		return _name;
	}
	
	/** Returns owner game object
	 * @return Owner game object
	 */
	public GameObject getOwnerGameObject() {
		return _ownerGameObject;
	}
	
	/** Returns number of items (if item is stackable)
	 * @return Number of items
	 */
	public int getNumOfItems() {
		return _numOfItems;
	}
	
	/** Returns cost
	 * @return Cost
	 */
	public int getCost() {
		return _cost;
	}
	
	/** Returns item weight
	 * @return Item weight
	 */
	public float getWeight() {
		return _weight;
	}
	
	/** Set owner game object
	 * @param obj - New owner game object
	 */
	public void setOwnerGameObject(GameObject obj) {
		_ownerGameObject = obj;
	}
	
	/** Set number of items (for stackable items */
	public void setNumOfItems(int num) {
		_numOfItems = num;
	}
	
	/** Enable item */
	public void on() {
		_isOn = true;
	}
	
	/** Use item 
	 * @return True if use item is complete
	 */
	public boolean use() throws SlickException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, ClassNotFoundException {
		return false;
	}

	/** Call when any object be attacked
	 * @param gameObject - Game object
	 */
	public void attack(GameObject gameObject) {
		
	}
	
	/** Disable item */
	public void off() {
		_isOn = false;
	}

	/** Draw info (for GUI)
	 * @param drawPos - Start draw position
	 * @param g - Slick2d Graphics
	 */
	public void drawInfo(Vector2f drawPos, Graphics g) {
		
	}
	
}
